/**
 * FileName: CareServiceImpl
 * Author:   P
 * Date:     2021/3/1 13:58
 * Description:
 */
package com.hospital.nurse.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hospital.nurse.mapper.CareMapper;
import com.hospital.nurse.mapper.PatientMapper;
import com.hospital.nurse.pojo.Care;
import com.hospital.nurse.pojo.Patient;
import com.hospital.nurse.service.CareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CareServiceImpl extends ServiceImpl<CareMapper, Care> implements CareService {

    @Autowired
    private CareMapper careMapper;
    @Autowired
    private PatientMapper patientMapper;


    @Override
    public PageInfo<Care> findAllCareAndPatient(int page,int size) {
        PageHelper.startPage(page,size);
        return new PageInfo<>(careMapper.findAllCareAndPatient());
    }

    @Override
    public Care findMoreCare(int cid) {
        return careMapper.findMoreCare(cid);
    }


    //逻辑删除
    @Override
    public boolean deleteCare(int cid) {
        Care care = careMapper.selectById(cid);
        care.setState("1");
        careMapper.updateById(care);
        return true;
    }

    @Override
    public PageInfo<Care> getCareByName(String name) {
        PageHelper.startPage(1,10);
        return new PageInfo<>(careMapper.getCareByPaitentName(name));
    }

    @Override
    public boolean addCare(Care care) {
        care.setCDate(new Date());
        careMapper.insert(care);
        return true;
    }
}
